from __future__ import division
from operator import itemgetter, attrgetter
from struct import *
import gc
import math
import matplotlib
import os
import pylab
import random
import sys
import time
from sets import Set
from scipy import stats
import numpy as np

print "Begins..."
inputFileName = "/home/diaosi/web-search-engine-wei_MOVE_FROM_PANGOLIN_20131206/polyIRIndexer/2014JanPruningResults/reproduceRomanQueryEffectiveness_20140121Night/04-06.topics.701-850.polyIRTKCompatibleMode"
inputFileHandler = open(inputFileName,"r")

outputFileName = "/home/diaosi/workspace/indri-5.6/runquery/04-06.topics.701-850.indriCompatibleMode"
outputFileHandler = open(outputFileName,"w")

outputFileHandler.write("<parameters>" + "\n")
for line in inputFileHandler.readlines():
    lineElements = line.strip().split(":")
    qidInStringFormat = lineElements[0]
    queryContent = lineElements[1]
    outputFileHandler.write("  <query>" + "\n")
    outputFileHandler.write("    <type>indri</type>" + "\n")
    outputFileHandler.write("    <number>" + str(qidInStringFormat) + "</number>" + "\n")
    outputFileHandler.write("    <text>" + str(queryContent) + "</text>" + "\n")
    outputFileHandler.write("  </query>" + "\n")
outputFileHandler.write("</parameters>" + "\n")
inputFileHandler.close()
outputFileHandler.close()
print "Overall:"
print "inputFileName:",inputFileName
print "outputFileName:",outputFileName
print "Ends."